import Vue from "vue";
import VueRouter from "vue-router";
import { sync } from "vuex-router-sync";
import TDesign from "tdesign-vue";
import App from "./App.vue";
import router from "./router";
import zhConfig from "tdesign-vue/es/locale/zh_CN";
import "./permission";
import store from "./store";
import * as echarts from "echarts";
import proxy from "@/config/host.ts";

import "tdesign-vue/es/style/index.css";
import "@/style/index.less";
import "./style/tdesgin-global.less";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "@/style/common-style.less";

import VueClipboard from "vue-clipboard2";
import axiosInstance, { download } from "@/utils/request";
import plugins from "./plugins"; // plugins
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree,bgxzfj} from "@/utils/commonSettings.js";
import { getDicts,getListData,submit,submit_delete,getSelectorData,importExcel,submit_delfile_fj,submit_delfile,
  getListData_fj,downloadFile,uploadFile,submit_qt,submit_qtsj,exportExcel,exportExcel_qt,submit_delfile_name,getListData_name
 } from "@/api/mainEntrance/system/dict/data";
// import { getConfigKey } from "@/api/mainEntrance/system/config";
import DictTag from "@/components/mainEntrance/dict-tag/index.vue";
import DictData from "@/components/mainEntrance/dict-data/index.js";
import Pagination from "@/components/mainEntrance/customize-pagination/index.vue";
import sjfw from "@/components/mainEntrance/qj-sjfw/index.vue";
import dgfj from "@/components/mainEntrance/qj-dgfj/index.vue";
import hdfj from "@/components/mainEntrance/qj-hdfj/index.vue";
import ckfj from "@/components/mainEntrance/qj-ckfj/index.vue";
import fy from "@/components/mainEntrance/qj-fy/index.vue";
import title from "@/components/mainEntrance/qj-title/index.vue";
import title1 from "@/components/mainEntrance/qj-title1/index.vue";
import qjshd from "@/components/mainEntrance/qjshd/index.vue";
import directive from "./directive";
import "virtual:svg-icons-register";
import SvgIcon from "@/components/mainEntrance/svg-icon/index.vue";
import pagePanel from "@/components/mainEntrance/page-panel/index.vue";
import infoWindow from "@/components/mainEntrance/info-window/index.vue";
import pagePanelNew from "@/components/mainEntrance/page-panel-new/index.vue";
import headerSearch from "@/components/mainEntrance/header-search/index.vue";

import "@/utils/filter";
import VXETable from "vxe-table";
import "vxe-table/lib/style.css";
import config from "../package.json";

import VForm from 'vform-builds'  //引入VForm库
import 'vform-builds/dist/VFormDesigner.css'  //引入VForm样式

import './utils/directive'
import './icons'
import '@/style/index.scss'
import '@/iconfont/iconfont.css'

const env = import.meta.env.MODE;

// 全局组件挂载
Vue.component("SvgIcon", SvgIcon);
Vue.component("Pagination", Pagination);
Vue.component("qjfy", fy);
Vue.component("qjsjfw", sjfw);
Vue.component("qjdgfj", dgfj);
Vue.component("qjhdfj", hdfj);
Vue.component("qjckfj", ckfj);
Vue.component("qjtitle", title);
Vue.component("qjshd", qjshd);
Vue.component("qjlswz", title1);
Vue.component("DictTag", DictTag);
Vue.component("t-page-header");
Vue.component("PagePanel", pagePanel);
Vue.component("InfoWindow", infoWindow);
Vue.component("PagePanelNew", pagePanelNew);
Vue.component("HeaderSearch", headerSearch);

Vue.use(VForm)  //全局注册VForm(同时注册了v-form-designer和v-form-render组件)

// 全局方法挂载
Vue.prototype.getDicts = getDicts;
Vue.prototype.$getListData = getListData; // 列表数据请求方法
Vue.prototype.$submit = submit; // 表单提交方法
Vue.prototype.$submit_delete = submit_delete; // 表单提交方法
Vue.prototype.$submit_qt = submit_qt; // 表单提交其他方法
Vue.prototype.$submit_qtsj = submit_qtsj; // 里面的方式不同
Vue.prototype.$exportExcel = exportExcel; // 导出Excel方法
Vue.prototype.$exportExcel_qt = exportExcel_qt; // 导出Excel方法
Vue.prototype.$getSelectorData = getSelectorData; // 字典数据请求方法
Vue.prototype.$submit_delfile_fj = submit_delfile_fj; // 删除附件方法
Vue.prototype.$importExcel = importExcel; // 删除附件方法
Vue.prototype.$submit_delfile_name = submit_delfile_name; // 删除附件方法
Vue.prototype.$getListData_name = getListData_name; // 附件列表数据请求方法
Vue.prototype.$submit_delfile = submit_delfile; // 删除附件方法
Vue.prototype.$getListData_fj = getListData_fj; // 附件列表数据请求方法
Vue.prototype.$downloadFile = downloadFile; // 下载附件方法
Vue.prototype.$uploadFile = uploadFile; // 上传附件方法
Vue.prototype.parseTime = parseTime;
Vue.prototype.resetForm = resetForm;
Vue.prototype.addDateRange = addDateRange;
Vue.prototype.selectDictLabel = selectDictLabel;
Vue.prototype.selectDictLabels = selectDictLabels;
Vue.prototype.handleTree = handleTree;
Vue.prototype.$bgxzfj = bgxzfj;
// Vue.prototype.getConfigKey = getConfigKey;
Vue.prototype.download = download;
Vue.prototype.$echarts = echarts;
Vue.prototype.$request = axiosInstance;
Vue.prototype.$bus = new Vue();

localStorage.setItem("contextRoot", proxy[env].processAPI);

document.title = proxy[env].WEB_TAG_NAME; // 修改网页标签名称
Vue.use(VXETable);
Vue.use(directive);
Vue.use(plugins);
Vue.use(ElementUI);
Vue.use(VueRouter);
Vue.use(TDesign);
Vue.use(VueClipboard);
DictData.install();

// 控制台打印当前系统版本号
window.console.log("当前系统版本：", config.version);
const originPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originPush.call(this, location).catch(err => err);
};

const originReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
  return originReplace.call(this, location).catch(err => err);
};

Vue.config.productionTip = false;
sync(store, router);
new Vue({
  router,
  store,
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  render: h => (
    <div>
      {/* 可以通过config-provider提供全局（多语言、全局属性）配置，如
      <t-config-provider globalConfig={enConfig}> */}
      <t-config-provider globalConfig={zhConfig}>
        <App />
      </t-config-provider>
    </div>
  )
}).$mount("#app");